<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
		<title>{:lang('pay')}</title>		
		<link rel="stylesheet" type="text/css" href="NC_PAY_WEB_CSS/wechatNative.css">
	</head>

	<body>
		<article class="nc-pay">
			<div class="pay-info">	
				<!-- start 支付信息 start -->
				<div class="p-left">
					<h3 class="p-title">请尽快付款！支付流水号：{$pay_data.out_trade_no}</h3>
					<p class="p-tips"></p>
				</div>
				<!-- end 支付信息 end -->
				<!-- start 支付金额 start -->
				<div class="p-right">
					<div class="p-price">
						<em>应付金额</em><strong>{$pay_data.pay_money}</strong><em>元</em>
					</div>
				</div>
				<!-- end 支付金额 end -->
			</div>	
			<!-- start 微信支付 start -->
			<div class="payment-qrcode clear">	
				<div class="p-w-hd">
					微信支付
					<div class="js-weixinInfo">距离二维码过期还剩<span class="font-red js-qrcode-time">41</span>秒，过期后请刷新页面重新获取二维码。</div>
				</div>
				<div class="p-w-bd clear">
					<div class="p-w-box">
						<div class="pw-box-hd">
							<img src="{php}echo __ROOT__ . '/' .$pay_qrcode;{/php}" id="weixinImageURL" width="298" height="298">
						</div>
						<div class="pw-box-ft">
							<p>请使用微信扫一扫</p>
							<p>扫描二维码支付</p>
						</div>
					</div>
					<div class="p-w-sidebar"></div>
				</div>
			</div>	
			<!-- end 微信支付 end -->
		</article>

		<script type="text/javascript">
			window.nc_url = {
            	baseUrl: "{:request()->root(true)}/",
            	route: ['{:request()->siteid()}', '{:request()->addon()}', '{:request()->module()}', '{:request()->controller()}', '{:request()->action()}'],
        	};
		</script>
		<script src="__STATIC__/js/jquery-2.2.js"></script>
		<script src="__STATIC__/js/common.js"></script>
		<script type="text/javascript">

			$(function() {
				setInterval("wchatOverdue()", 1000);
			})

			function wchatOverdue() {
				var time = parseInt($(".js-qrcode-time").text());
				if (time != 0) {
					$(".js-qrcode-time").text(--time);
				} else {
					$(".js-weixinInfo").html("<span class='font-red'>二维码已过期，<a href='' style='color:#10ADF6;'>刷新</a>页面重新获取二维码</span>");
					$("#weixinImageURL").attr("src","NC_PAY_WEB_IMG/57b51ea9Nb862ca5e.png").css({"width": "278px","height": "278px","margin": "10px 0 0 10px"});
				}
			}

			var payStatus = window.setInterval("payStatu()", 2000);

			function payStatu(){
				$.ajax({
					type : "post",
					url : "{:addon_url('Pay://common/pay/getPayResult')}",
					data : {
						out_trade_no : "{$pay_data.out_trade_no}"
					},
					success : function(data){
						if(data.data > 0){
							location.href = "{:append_url_params($pay_data.return_url, ['status' => 1])}";
							clearInterval(payStatus);
						}
					}
				})
			}
		</script>	
	</body>
</html>
